package com.lvjian.community.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.lvjian.community.domain.ResidentList;
import com.lvjian.community.service.ResidentListService;
import com.lvjian.community.utils.Consts;

/**
 * 居民列表controller
 */
@RestController
public class ResidentListController {

    @Autowired
    private ResidentListService residentListService;

    @RequestMapping(value = "/api/residents", method = RequestMethod.GET)
    @ResponseBody
    public Object getResidentList(HttpServletRequest request, HttpSession session) {
        List<ResidentList> residentList = residentListService.getResidentList();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(Consts.CODE, 1);
        jsonObject.put("data", residentList);
        return jsonObject;
    }
}
